﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iOak.Data.Resumes;
using iOak.Domain.Resumes;

namespace iOak.Business.Resumes
{
    public class CompanyService
    {
        private CompanyRepository _companyRepository;
        public CompanyService()
        {
            _companyRepository = new CompanyRepository("master");
        }

        public void Create(Company company)
        {
            _companyRepository.Create(company);
        }

        public Company Retrieve(Guid companyId)
        {
            return _companyRepository.Retrieve(companyId);
        }

        public void Update(Company company)
        {
            _companyRepository.Update(company);
        }

        public void Delete(Guid companyId)
        {
            var company = _companyRepository.Retrieve(companyId);

            if (company != null)
                _companyRepository.Delete(companyId);
        }

        public List<Company> LoadAll()
        {
            return _companyRepository.LoadAll();
        }

        public Company GetByName(String companyName)
        {
            return _companyRepository.GetByName(companyName);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="companyName">公司名称</param>
        /// <param name="isActive">是否审核通过</param>
        /// <param name="keyword">关键字</param>
        /// <param name="orderbyIndicator">排序指示：1-更新日期升序；2-更新日期降序</param>
        /// <returns></returns>
        public List<Company> Select(string companyName, bool? isActive, string keyword, int orderbyIndicator)
        {
            return _companyRepository.Select(companyName, isActive, keyword, orderbyIndicator);
        }
    }
}
